var assert = require('chai').assert;
var request = require('request');
var config = require('../app/config/config.js');

// var showDebug = true;
var debug = (typeof showDebug !== 'undefined') ? console.log.bind(console) : function() {};

var httpBaseUrl = 'http://localhost:' + config.http.port + config.http.baseUrl;
suite('test api/v1/vendor', function() {
	var __url = httpBaseUrl + '/v1/vendor';
	var aItem = {
		name: 'vendor_abc'
	};

	test('[x] create vendor', function(done) {
		request({
			method: 'POST',
			url: __url,
			body: aItem,
			json: true,
			headers: {
				"content-type": "application/json"
			}
		}, function(err, res, body) { // body is object
			debug(body);
			assert.equal(res.statusCode, 200);
			var code = body.errCode;
			assert.isTrue(code === 0 || code === 2300); // 2300 = exists
			done();
		});
	});
});